package com.xzz.feign.feignFallback;

import com.xzz.domain.Login;
import com.xzz.enums.GlobalErrorCode;
import com.xzz.feign.LoginFeignClient;
import com.xzz.result.JSONResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class LoginFeignClientFallbackFactory implements FallbackFactory<LoginFeignClient> {
    @Override
    public LoginFeignClient create(Throwable throwable) {
        throwable.printStackTrace();
        return new LoginFeignClient() {
            @Override
            public JSONResult saveOrUpdate(Login login) {
                return JSONResult.error(GlobalErrorCode.SERVICE_ERROR);
            }
        };
    }
}